<template>
  <div class="apply-dialog">
    <el-dialog
      title=""
      :visible.sync="dialogVisible"
      :fullscreen="true"
      :before-close="handleClose"
      :close-on-click-modal="false"
      :show-close="false"
    >
      <LimitTech ref="LimitTech" @showTech="openTech" />
      <Tech ref="Tech" @showLimit="openHelp" />
      <div slot="title" class="flex flex-row align-center justify-content-end">
        <div class="btn-list flex flex-row align-center">
          <!-- <el-button type="primary" size="mini" @click="handlePrint(printData)">
            导出PDF
          </el-button> -->
          <el-button
            v-if="btnShow"
            type="primary"
            size="mini"
            :disabled="submitDisabled"
            @click="submitAction"
          >
            提交
          </el-button>
          <!-- <el-button v-if="!pdfLoading" type="primary" size="mini" @click="outPutPdfFn()">
            导出PDF
          </el-button> -->
          <!-- <el-button v-else type="primary" size="mini" :loading="true">
            正在导出
          </el-button> -->
          <!--          <div class="pl15 pr15">
            上报人：<span class="primary-color">{{
              processStructureValue.workOrder.createdName
            }}</span>
          </div>
          <div class="pl15 pr15">
            最新状态：<span
              v-if="processStructureValue.workOrder.status == 2"
              class="danger-color"
            >已撤回</span>
            <span
              v-if="processStructureValue.workOrder.status == 3"
              class="danger-color"
            >已驳回</span>
            <span
              v-if="processStructureValue.workOrder.status == 0"
              class="primary-color"
            >{{ processStructureValue.workOrder.current_state_name }}</span><span
              v-if="processStructureValue.workOrder.principals != ''"
              class="ml20"
            >当前处理人：</span><span
              v-if="processStructureValue.workOrder.principals != ''"
              class="danger-color"
            >【{{ processStructureValue.workOrder.principals }}】</span>
          </div>-->
          <div class="ml20" @click="handleClose">
            <i class="el-icon-close cursor-p font22 line-height-32" />
          </div>
        </div>
      </div>
      <div v-if="dialogVisible" class="text item reviewFrom">
        <div id="pdfHtml" class="app-container flex flex-row">
          <div class="left flex-auto ">
            <el-card
              class="box-card apply-box mt10 mb20"
            >
              <div slot="header" class="clearfix flex flex-row align-center">
                <div class="line" />
                <span class="font18 ml10 flex-auto">申报者</span>
                <!--                <el-button
                  id="no-print"
                  type="danger"
                  round
                  icon="el-icon-thumb"
                  size="small"
                  @click="openHelp"
                >申报指引</el-button>-->
              </div>

              <el-form
                ref="generateForm"
                label-suffix=":"
                size="small"
                :model="models"
                label-position="right"
                label-width="180px"
                :disabled="true"
              >
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="项目名称"
                      prop="name"
                      label-width="130px"
                    >
                      <el-input
                        v-model="models.name"
                        :style="{width:'100%'}"
                        placeholder="请输入项目名称"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="项目编号"
                      prop="project_no_block"
                    >
                      <el-input
                        v-model="models.projectNo"
                        :style="{width:'100%'}"
                        placeholder="请输入项目编号"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="项目分类"
                      prop="projectClass"
                      label-width="130px"
                    >
                      <el-select
                        v-model="models.projectClass"
                        :style="{width:'100%'}"
                        placeholder="请选择项目分类"
                        :filterable="false"
                        clearable
                        value=""
                      >
                        <el-option
                          v-for="(item, index) in [{label:'非限制',value:1},{label:'限制类',value:2},{label:'上海首家',value:3}]"
                          :key="index"
                          :value="item.value"
                          :label="item.label"
                        />

                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="申请科室"
                      prop="applyDeptId"
                    >
                      <el-select
                        v-model="models.applyDeptId"
                        :style="{width:'100%'}"
                        placeholder="请选择科室"
                        :filterable="false"
                        clearable
                        value=""
                        @change="handleChange"
                      >
                        <el-option
                          v-for="(item, index) in structureList"
                          :key="item.id"
                          :value="item.id"
                          :label="item.depName"
                        />

                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col :span="8">
                    <el-form-item label="技术类别" prop="techType" label-width="130px">
                      <el-cascader
                        v-model="techTypeArr"
                        :options="categoryCatalog"
                        :style="{ width: '100%' }"
                        placeholder="请选择技术类别"
                        clearable
                      />
                    </el-form-item>
                  </el-col>
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="项目负责人"
                      prop="applyManagerName"
                    >
                      <el-input
                        v-model="models.applyManagerName"
                        :style="{width:'100%'}"
                        placeholder="请输入项目负责人"
                        disabled
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <!-- <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="项目负责人工号"
                      prop="projectManagerEmp"
                      label-width="130px"
                    >
                      <el-input
                        v-model="models.projectManagerEmp"
                        :style="{width:'100%'}"
                        placeholder="请输入项目负责人工号"
                      />
                    </el-form-item>
                  </el-col> -->
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="项目负责人联系方式"
                      prop="projectManagerContact"
                    >
                      <el-input
                        v-model="models.projectManagerContact"
                        :style="{width:'100%'}"
                        placeholder="请输入项目负责人联系方式"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="目标例数"
                      prop="targetNumber"
                    >
                      <el-input
                        v-model="models.targetNumber"
                        :style="{width:'100%'}"
                        placeholder="请输入目标例数"
                        type="number"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="项目成员"
                      prop="projectMember"
                      label-width="130px"
                    >
                      <div class="member-select-container">
                        <el-cascader
                          v-model="models.projectMember"
                          :options="departmentUserOptions"
                          :props="{
                            multiple: true,
                            value: 'id',
                            label: 'name',
                            children: 'children',
                            checkStrictly: true,
                            emitPath: false,
                            expandTrigger: 'hover',

                          }"
                          :style="{width:'100%'}"
                          placeholder="请选择项目成员"
                          :show-all-levels="false"
                          @change="handleMemberChange"
                        />
                      </div>
                      <!-- 显示选中的完整姓名 -->
                      <div v-if="selectedMemberNames.length > 0" class="selected-members">
                        <div class="selected-title">已选成员：</div>
                        <div class="selected-names">
                          <el-tag
                            v-for="(name, index) in selectedMemberNames"
                            :key="index"
                            size="small"
                            type="info"
                            class="member-tag"
                          >
                            {{ name }}
                          </el-tag>
                        </div>
                      </div>
                    </el-form-item>
                  </el-col>
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="填报人姓名"
                      prop="applyUserName"
                    >
                      <el-input
                        v-model="models.applyUserName"
                        :style="{width:'100%'}"
                        placeholder="请输入填报人姓名"
                        disabled
                      />
                    </el-form-item>
                  </el-col>
                </el-row>

                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="填报人工号"
                      prop="workNumber"
                    >
                      <el-input
                        v-model="models.workNumber"
                        :style="{width:'100%'}"
                        placeholder="请输入工号"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="填报时间"
                      prop="fillTime"
                      label-width="130px"
                    >
                      <el-input
                        v-model="models.fillTime"
                        :style="{width:'100%'}"
                        placeholder="请输入项目名称"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="16"
                  >
                    <el-form-item
                      label="设备名称"
                      prop="deviceNames"
                      label-width="130px"
                    >
                      <el-input
                        v-model="models.deviceNames"
                        type="textarea"
                        :rows="3"
                        placeholder="请输入设备名称"
                        :style="{ width: '62%' }"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <!-- <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="设备或试剂"
                      prop="equipmentReagentsExist"
                    >
                      <el-radio-group
                        v-model="models.equipmentReagentsExist"
                        :style="{ width: 130 }"
                      >
                        <el-radio
                          v-for="(item, index) in [{label:'有',value:1},{label:'无',value:0}]"
                          :key="index"
                          class="incat-radio incat-mini"
                          :style="{display: 'inline-block'}"
                          :label="item.value"
                        >
                          <template>{{ item.label }}</template>
                        </el-radio>
                      </el-radio-group>
                    </el-form-item>
                  </el-col>
                </el-row> -->
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <!-- <el-col
                    :span="16"
                  >
                    <el-form-item
                      label="备注"
                      prop="remark"
                      label-width="130px"
                    >
                      <el-input
                        v-model="models.remark"
                        type="textarea"
                        :rows="3"
                        placeholder="请输入项目名称"
                        :style="{ width: '62%' }"
                      />
                    </el-form-item>
                  </el-col> -->
                </el-row>
                <!-- <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="16"
                  >
                    <el-form-item
                      label="申请书"
                      prop="applyDocs"
                      label-width="130px"
                    >
                      <FileUpload :element="uploadConfig" :data-model="models.applyDocs&&JSON.parse(models.applyDocs)" :preview="true" />
                    </el-form-item>
                  </el-col>
                </el-row> -->
                <!-- <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="16"
                  >
                    <el-form-item
                      label="设备三证"
                      prop="deviceDocs"
                      label-width="130px"
                    >
                      <FileUpload :element="uploadConfig" :data-model="models.deviceDocs&&JSON.parse(models.deviceDocs)" :preview="true" />
                    </el-form-item>
                  </el-col>
                </el-row> -->
                <!-- <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="16"
                  >
                    <el-form-item
                      label="设备三证为"
                      label-width="130px"
                    >
                      <span>*</span>
                      <span
                        style="{'font-size':'15px','font-weight':'500',color:'#606266'}"
                      >
                        《医疗器械生产企业许可证》、《医疗器械注册证》和《医疗器械经营企业许可证》。
                      </span>
                    </el-form-item>
                  </el-col>
                </el-row> -->
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="16"
                  >
                    <el-form-item
                      label="补充资料"
                      prop="additionalDocs"
                      label-width="130px"
                    >
                      <FileUpload :element="uploadConfig" :data-model="models.additionalDocs&&JSON.parse(models.additionalDocs)" :preview="true" />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="16"
                  >
                    <el-form-item
                      label="补充资料说明"
                      label-width="130px"
                    >
                      <div>
                        <span>*</span>
                        <span style="font-size: 15px;font-weight: 400;color:#606266">
                          如有培训证明，请上传
                        </span>
                      </div>
                      <!-- <div>
                        <span>*</span>
                        <span style="font-size: 15px;font-weight: 400;color:#606266">
                      如属本市首次开展的医疗技术，需上传第三方评价机构出具的确认需纳入本市限制类技术目录的评估报告
                    </span>
                      </div> -->
                      <div>
                        <span>*</span>
                        <span style="font-size: 15px;font-weight: 400;color:#606266">
                          其他申请所需材料也可上传为补充资料
                        </span>
                      </div>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>

            </el-card>

            <el-card class="box-card apply-box mb20">
              <div slot="header" class="clearfix flex flex-row align-center height32">
                <div class="line" />
                <span class="font16 ml10 flex-auto">审批历史</span>
              </div>
              <div class="text item pt10 pb10 pl10 pr10">
                <el-table :data="circulationHistoryList" border style="width: 100%" stripe max-height="600">
                  <el-table-column prop="id" label="#" align="center" type="index" width="70" />
                  <el-table-column prop="processOper" label="任务名称" align="center" />
                  <el-table-column prop="processBy" label="处理人" align="center" />
                  <el-table-column prop="status" label="审批操作" align="center">
                    <template slot-scope="scope">
                      <div v-if="scope.row.auditStatus == 1">
                        审批通过
                      </div>
                      <div v-if="scope.row.auditStatus == 2">
                        审批驳回
                      </div>
                    </template>
                  </el-table-column>
                  <el-table-column prop="remarks" label="审批意见" align="center" :show-overflow-tooltip="true" />
                  <!-- <el-table-column prop="circulation" label="流转" align="center" /> -->
                  <el-table-column prop="updateTime" label="处理时间" align="center" width="180" />
                  <el-table-column prop="status" label="状态" align="center" width="90">
                    <template slot-scope="scope">
                      <div v-if="scope.row.status == 0" class="warning-color">
                        待处理
                      </div>
                      <div v-if="scope.row.status == 1" class="primary-color">
                        已处理
                      </div>
                      <div v-if="scope.row.status == 2" class="primary-color">
                        无需处理
                      </div>
                    </template>
                  </el-table-column>
                  <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="250">
                    <template slot-scope="scope">
                      <el-button size="mini" type="text" icon="el-icon-document" @click="handleDetail(scope.row)">附加信息</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
            </el-card>

            <el-card v-if="models.status===10&&btnShow" class="box-card apply-box mb20">
              <div slot="header" class="clearfix flex flex-row align-center height32">
                <div class="line" />
                <span class="font16 ml10 flex-auto">科室负责人初审</span>
              </div>
              <el-form
                ref="departmentForm"
                label-suffix=":"
                size="small"
                :model="departmentTake"
                label-position="right"
                label-width="100px"
              >
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="初审结果"
                      prop="auditStatus"
                      label-width="130px"
                    >
                      <el-select
                        v-model="departmentTake.auditStatus"
                        :style="{width:'100%'}"
                        placeholder="请选择初审结果"
                        :filterable="false"
                        clearable
                        value=""
                      >
                        <el-option
                          v-for="(item, index) in [{label:'通过',value:1},{label:'驳回',value:4}]"
                          :key="index"
                          :value="item.value"
                          :label="item.label"
                        />

                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="16"
                  >
                    <el-form-item
                      label="审批意见"
                      prop="remarks"
                      label-width="130px"
                    >
                      <el-input
                        v-model="departmentTake.remarks"
                        type="textarea"
                        :rows="3"
                        placeholder="请输入审批意见"
                        :style="{ width: '62%' }"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
            </el-card>

            <el-card v-if="models.status===20&&btnShow" class="box-card apply-box mb20">
              <div slot="header" class="clearfix flex flex-row align-center height32">
                <div class="line" />
                <span class="font16 ml10 flex-auto">医务部初审</span>
              </div>
              <el-form
                ref="departmentForm"
                label-suffix=":"
                size="small"
                :model="medicalTake"
                label-position="right"
                label-width="100px"
              >
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="初审结果"
                      prop="auditStatus"
                      label-width="130px"
                    >
                      <el-select
                        v-model="medicalTake.auditStatus"
                        :style="{width:'100%'}"
                        placeholder="请选择初审结果"
                        :filterable="false"
                        clearable
                        value=""
                      >
                        <el-option
                          v-for="(item, index) in [{label:'通过',value:1},{label:'驳回',value:4}]"
                          :key="index"
                          :value="item.value"
                          :label="item.label"
                        />

                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="16"
                  >
                    <el-form-item
                      label="初审意见"
                      prop="remarks"
                      label-width="130px"
                    >
                      <el-input
                        v-model="medicalTake.remarks"
                        type="textarea"
                        :rows="3"
                        placeholder="请输入初审意见"
                        :style="{ width: '62%' }"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
            </el-card>

            <el-card v-if="models.status===30&&btnShow" class="box-card apply-box mb20">
              <div slot="header" class="clearfix flex flex-row align-center height32">
                <div class="line" />
                <span class="font16 ml10 flex-auto">伦理委员会</span>
              </div>
              <el-form
                ref="ethicsTakeForm"
                label-suffix=":"
                size="small"
                :model="ethicsTake"
                label-position="right"
                label-width="100px"
              >
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="审核结果"
                      prop="auditStatus"
                      label-width="130px"
                    >
                      <el-select
                        v-model="ethicsTake.auditStatus"
                        :style="{width:'100%'}"
                        placeholder="请选择审核结果"
                        :filterable="false"
                        clearable
                        value=""
                      >
                        <el-option
                          v-for="(item, index) in [{label:'通过',value:1},{label:'驳回',value:4}]"
                          :key="index"
                          :value="item.value"
                          :label="item.label"
                        />

                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="16"
                  >
                    <el-form-item
                      label="初审意见"
                      prop="remarks"
                      label-width="130px"
                    >
                      <el-input
                        v-model="ethicsTake.remarks"
                        type="textarea"
                        :rows="3"
                        placeholder="请输入初审意见"
                        :style="{ width: '62%' }"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="16"
                  >
                    <el-form-item
                      label="附件"
                      prop="attach"
                      label-width="130px"
                    >
                      <FileUpload :element="uploadConfig" :preview="false" @fileList="fileList2" />
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
            </el-card>

            <el-card v-if="models.status===120&&btnShow" class="box-card apply-box mb20">
              <div slot="header" class="clearfix flex flex-row align-center height32">
                <div class="line" />
                <span class="font16 ml10 flex-auto">管理委员会</span>
              </div>
              <el-form
                ref="ethicsTakeForm"
                label-suffix=":"
                size="small"
                :model="managerTake"
                label-position="right"
                label-width="100px"
              >
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col :span="8">
                    <el-form-item
                      label="审核评分"
                      prop="auditStatus"
                      label-width="130px"
                    >
                      <el-input-number v-model="managerTake.score" :style="{width:'100%'}" :step="10" :min="1" :max="100" label="评分" @change="handleScoreChange" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" style="margin-top: 7px">
                    <span style="color: red"> {{ scoreDesc }}</span>
                  </el-col>
                </el-row>

                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col :span="8">
                    <el-form-item
                      label="审核结果"
                      prop="auditStatus"
                      label-width="130px"
                    >
                      <span :class="managerTake.auditStatus === 1 ? 'green':'red'"> {{ scoreResult }}</span>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="16"
                  >
                    <el-form-item
                      label="初审意见"
                      prop="remarks"
                      label-width="130px"
                    >
                      <el-input
                        v-model="managerTake.remarks"
                        type="textarea"
                        :rows="3"
                        placeholder="请输入初审意见"
                        :style="{ width: '62%' }"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="16"
                  >
                    <el-form-item
                      label="附件"
                      prop="attach"
                      label-width="130px"
                    >
                      <FileUpload :element="uploadConfig" :preview="false" @fileList="fileList3" />
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
            </el-card>

            <el-card v-if="models.status===40&&btnShow" class="box-card apply-box mb20">
              <div slot="header" class="clearfix flex flex-row align-center height32">
                <div class="line" />
                <span class="font16 ml10 flex-auto">院内评审</span>
              </div>
              <el-form
                ref="insuranceForm"
                label-suffix=":"
                size="small"
                :model="hospitalTake"
                label-position="right"
                label-width="100px"
              >
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="审核结果"
                      prop="auditStatus"
                      label-width="130px"
                    >
                      <el-select
                        v-model="hospitalTake.auditStatus"
                        :style="{width:'100%'}"
                        placeholder="请选择审核结果"
                        :filterable="false"
                        clearable
                        value=""
                      >
                        <el-option
                          v-for="(item, index) in [{label:'通过',value:1},{label:'驳回',value:4}]"
                          :key="index"
                          :value="item.value"
                          :label="item.label"
                        />

                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="16"
                  >
                    <el-form-item
                      label="审核意见"
                      prop="remarks"
                      label-width="130px"
                    >
                      <el-input
                        v-model="hospitalTake.remarks"
                        type="textarea"
                        :rows="3"
                        placeholder="请输入审核意见"
                        :style="{ width: '62%' }"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
            </el-card>

            <el-card v-if="models.status===50&&btnShow" class="box-card apply-box mb20">
              <div slot="header" class="clearfix flex flex-row align-center height32">
                <div class="line" />
                <span class="font16 ml10 flex-auto">医保办</span>
              </div>
              <el-form
                ref="insuranceForm"
                label-suffix=":"
                size="small"
                :model="insuranceTake"
                label-position="right"
                label-width="100px"
              >
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="16"
                  >
                    <el-form-item
                      label="项目名称"
                      prop="remark"
                      label-width="100px"
                    >
                      <el-input
                        v-model="models.name"
                        placeholder="请输入项目名称"
                        :style="{ width: '100%' }"
                        disabled
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="医保编码"
                      prop="insuranceNo"
                    >
                      <el-input
                        v-model="insuranceTake.insuranceNo"
                        :style="{width:'100%'}"
                        placeholder="请输入医保编码"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="支付类型"
                      prop="payType"
                      label-width="130px"
                    >
                      <el-select
                        v-model="insuranceTake.payType"
                        :style="{width:'100%'}"
                        placeholder="请选择支付类型"
                        :filterable="false"
                        clearable
                        value=""
                      >
                        <el-option
                          v-for="(item, index) in [{label:'个人',value:1},{label:'医保',value:2}]"
                          :key="index"
                          :value="item.value"
                          :label="item.label"
                        />

                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
            </el-card>

            <el-card v-if="models.status===60&&btnShow" class="box-card apply-box mb20">
              <div slot="header" class="clearfix flex flex-row align-center height32">
                <div class="line" />
                <span class="font16 ml10 flex-auto">财务审核</span>
              </div>
              <el-form
                ref="insuranceForm"
                label-suffix=":"
                size="small"
                :model="financeTake"
                label-position="right"
                label-width="100px"
              >
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="项目名称"
                      prop="name"
                      label-width="130px"
                    >
                      <el-input
                        v-model="models.name"
                        placeholder="请输入项目名称"
                        :style="{width:'100%'}"
                        disabled
                      />
                    </el-form-item>
                  </el-col>
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="医保编码"
                      prop="name"
                      label-width="100px"
                    >
                      <el-input
                        v-model="models.name"
                        placeholder="请输入医保编码"
                        :style="{width:'100%'}"
                        disabled
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="收费名称"
                      prop="payName"
                      label-width="130px"
                    >
                      <el-input
                        v-model="financeTake.payName"
                        :style="{width:'100%'}"
                        placeholder="收费名称"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="收费价格"
                      prop="payPrice"
                    >
                      <el-input
                        v-model="financeTake.payPrice"
                        :style="{width:'100%'}"
                        placeholder="请输入收费价格"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>

                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="16"
                  >
                    <el-form-item
                      label="开通时间"
                      prop="openTime"
                      label-width="130px"
                    >
                      <el-date-picker
                        v-model="financeTake.openTime"
                        type="date"
                        :style="{ width: '32%' }"
                        placeholder="请选择开通时间"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
            </el-card>

            <el-card v-if="models.status===70&&btnShow" class="box-card apply-box mb20">
              <div slot="header" class="clearfix flex flex-row align-center height32">
                <div class="line" />
                <span class="font16 ml10 flex-auto">医务处开通</span>
              </div>
              <el-form
                ref="insurance1Form"
                label-suffix=":"
                size="small"
                label-position="right"
                label-width="100px"
              >
                <el-row
                  type="flex"
                  :gutter="30"
                  justify="start"
                  align="top"
                >
                  <el-col
                    :span="8"
                  >
                    <el-form-item
                      label="项目名称"
                      prop="name"
                      label-width="130px"
                    >
                      <el-input
                        v-model="models.name"
                        placeholder="请输入项目名称"
                        :style="{width:'100%'}"
                        disabled
                      />
                    </el-form-item>
                  </el-col>
                  <el-col
                    :span="8"
                  >
                    确认并通知申报人
                  </el-col>
                </el-row>
              </el-form>
            </el-card>

          </div>
        </div>
      </div>
    </el-dialog>
    <el-dialog
      title="附加信息"
      :visible.sync="detailDialogVisible"
      width="30%"
    >
      <div class="flex flex-column">
        <div v-for="(item, index) in detailData" :key="index" class="flex mt20">
          <span>{{ otherkeyMaps[item.key] }}: </span>
          <div v-if="item.key==='attach'">
            <span v-for="file in item.value">
              <a style="color: #0d84ff;" :href="file.url">{{ file.name }}，</a>
            </span>
          </div>
          <span v-else-if="item.key==='auditStatus'" />
          <span v-else-if="item.key==='payType'">
            {{ item.value===1?'个人' : '医保' }}
          </span>
          <span v-else>{{ item.value }}</span>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="detailDialogVisible = false">关闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import Vue from 'vue'
import { Message, Loading } from 'element-ui'
import { GenerateForm } from '@/components/VueFormMaking'
import 'form-making/dist/FormMaking.css'
Vue.component(GenerateForm.name, GenerateForm)
import LimitTech from './limitTech/index.vue'
import Tech from './tech/index.vue'
import { getDuration } from '@/utils/costum'
import {
  processStructure,
  handleWorkOrder,
  activeOrder, newDoApprove, newWorkOrderList, selectProjectNumbera
} from '@/api/xjs/work-order'
import { listAllUser, newListUser } from '@/api/system/sysuser'
import { getNewDeptInfo, getNewDeptList, getOrdinaryDeptList, newGetUserList, newTreeselect } from '@/api/system/dept'
import { mapGetters } from 'vuex'
import printJS from 'print-js'
import FileUpload from '@/components/VueFormMaking/components/Upload/file.vue'
import moment from 'moment/moment'
import { newGetUserInfo } from '@/api/user'
export default {
  name: 'ApplyDialog',
  components: {
    FileUpload,
    LimitTech,
    Tech
  },
  props: {
    value: {
      type: String,
      default: ''
    },
    listData: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      uploadConfig: {
        options: {
          // action: "http://192.168.0.107:8002/api/v1/public/uploadFile?file_type=files"
          defaultValue: [],
          disabled: false,
          length: 9,
          tip: '',
          width: '30%'
        }
      },
      techTypeArr: [], // 技术类型
      categoryCatalog: [
        {
          value: 1,
          label: '手术操作类',
          children: [
            { value: 11, label: '一级项目（国内医院尚未开展的技术项目）' },
            { value: 12, label: '二级项目（本学科近年来发展成熟的、在国内已有医院开展、省内及本院尚未开展）' },
            { value: 13, label: '三级项目（本学科发展成熟，在国内及省内均有开展，而本院尚未开展）' },
            { value: 14, label: '四级项目（报备类项目，创新性一般，技术含量不高，仅为设备、试剂、耗材等引进或调整，在本院尚未开展的技术项目）' }
          ]
        },
        {
          value: 2,
          label: '非手术操作类',
          children: [
            { value: 21, label: '一级项目（国内医院尚未开展的技术项目）' },
            { value: 22, label: '二级项目（本学科近年来发展成熟的、在国内已有医院开展、省内及本院尚未开展）' },
            { value: 23, label: '三级项目（本学科发展成熟，在国内及省内均有开展，而本院尚未开展）' },
            { value: 24, label: '四级项目（报备类项目，创新性一般，技术含量不高，仅为设备、试剂、耗材等引进或调整，在本院尚未开展的技术项目）' }
          ]
        }
      ],
      departmentUserOptions: [], // 部门-用户级联数据
      selectedMemberNames: [], // 存储选中的成员姓名
      allUsers: [], // 存储所有用户数据
      displayUserGroups: [], // 按部门分组的用户数据
      structureList: [],
      structureUserList: [],
      models: {

      },
      submitDisabled: false,
      departmentTake: {},
      medicalTake: {},
      ethicsTake: {},
      managerTake: { score: 60 },
      hospitalTake: {},
      insuranceTake: {},
      financeTake: {},
      btnShow: true,
      take: {
        departmentTake: {},
        medicalTake: {},
        ethicsTake: {},
        managerTake: {},
        hospitalTake: {},
        insuranceTake: {},
        financeTake: {}
      },
      timelineShow: false,
      timeLine: [],
      getDuration,
      pdfLoading: false,
      loadingFull: null,
      ops: {
        vuescroll: {
          mode: 'native',
          sizeStrategy: 'percent',
          detectResize: true,
          locking: true
        },
        scrollPanel: {
          maxHeight: 800
        },
        bar: {
          background: '#277fd6',
          size: '3px',
          keepShow: true
        },
        rail: {
          background: '#E0E8F0',
          opacity: 1,
          size: '3px',
          specifyBorderRadius: false,
          gutterOfEnds: '50px',
          gutterOfSide: '0px',
          keepShow: false
        }
      },
      printData: {
        printable: 'printFrom',
        header: '',
        ignore: ['no-print']
      },
      limitTechList: [],
      selectLimitData: [],
      loading: false,
      dialogVisible: false,
      limitTechVisible: false,
      isLoadingStatus: true,
      currentNode: {
        hideTpls: null,
        writeTpls: null
      },
      isActiveProcessing: false,
      tpls: [],
      remarks: '', // 备注信息
      alertMessage: '',
      nodeStepList: [],
      circulationHistoryList: [],
      activeIndex: 0,
      processStructureValue: {
        workOrder: { title: '' }
      },
      ruleForm: {
        title: '',
        projectNo: '',
        process: '',
        classify: '',
        state_id: '',
        state: '',
        source_state: '',
        processor: '',
        process_method: '',
        tpls: [],
        tasks: []
      },
      processId: null,
      workOrderId: null,
      remoteFunc: {
        // 获取用户列表
        async userList(resolve) {
          const res = await listAllUser({})
          const options = res.data
          resolve(options)
        },
        async deptTreeList(resolve) {
          const res = await getOrdinaryDeptList()
          resolve(res.data)
        }
      },
      detailDialogVisible: false,
      detailData: null,
      otherkeyMaps: {
        auditStatus: '审核状态',
        payName: '收费名称',
        payPrice: '支付价格',
        openTime: '开通时间',
        insuranceNo: '医保编码',
        payType: '支付方式',
        remarks: '备注',
        attach: '附件'
      },
      scoreDesc: '评分小于60分，项目不通过；评分大于等于60分，项目通过',
      scoreResult: '通过'
    }
  },
  computed: {
    ...mapGetters(['name', 'userId', 'newUserInfo', 'globalConfig'])
  },
  methods: {
    handleDetail(row) {
      console.log('row', row)
      if (row.task && row.task !== '{}') {
        try {
          const taskObj = JSON.parse(row.task)
          this.detailData = Object.entries(taskObj).map(([key, value]) => ({ key, value }))
          console.log('detailData', this.detailData)
          this.detailDialogVisible = true
        } catch (error) {
          console.error('解析 task 字段失败', error)
          this.$message.error('解析 task 字段失败')
        }
      } else {
        this.$message.warning('该条记录没有附加信息')
      }
    },
    fileList2(files) {
      // this.models.additionalDocsTemp = files;
      this.ethicsTake.attach = files
    },
    fileList3(files) {
      // this.models.additionalDocsTemp = files;
      this.managerTake.attach = files
    },
    getHistoryState(item) {
      if (item.circulation == '结束') {
        return '审批完成'
      } else if (item.circulation == '已撤回') {
        return '已撤回'
      } else {
        if (item.status == 2) {
          if (item.target != '') {
            return '提交申报'
          } else {
            return '转交'
          }
        } else if (item.status == 0) {
          return '审批驳回'
        } else {
          return '审批通过'
        }
      }
    },
    getHistoryTag(item) {
      if (item.circulation == '结束') {
        return 'success'
      } else if (item.circulation == '已撤回') {
        return 'danger'
      } else {
        if (item.status == 2) {
          if (item.target != '') {
            return ''
          } else {
            return 'warning'
          }
        } else if (item.status == 0) {
          return 'danger'
        } else {
          return 'success'
        }
      }
    },
    guitda() {
      selectProjectNumbera().then(res => {
        this.models.projectNo = res.total.toString()
      })
    },
    open(row, btnShow) {
      this.guitda()
      // 先保存传入的数据，避免被覆盖
      const originalData = { ...row }
      console.log('原始数据:', originalData)

      // 获取用户列表
      this.usreMesssageList = newListUser({ currentPage: 1, pageSize: 10, empNo: null, deptID: '', userID: '', userName: '' }).then(res => {
        if (res.records) {
          // 过滤有效数据并保存
          this.allUsers = res.records.filter(user =>
            user.vldFG === '0' && user.name && user.empNo
          )
          this.groupAndDisplayUsers(this.allUsers)

          // 处理项目成员回显
          if (originalData && originalData.projectMember) {
            console.log('原始项目成员数据:', originalData.projectMember)
            // 将字符串格式的成员ID转换为数组
            const memberIds = originalData.projectMember.split(',').filter(id => id)
            console.log('转换后的成员ID数组:', memberIds)

            // 确保在设置models.projectMember之前已经构建了departmentUserOptions
            this.$nextTick(() => {
              this.models.projectMember = memberIds

              // 更新选中的成员姓名
              this.selectedMemberNames = memberIds.map(id => {
                const user = this.allUsers.find(u => u.id === Number(id) || u.id === id)
                return user ? user.name : ''
              }).filter(name => name)

              console.log('回显项目成员:', this.models.projectMember)
              console.log('回显成员姓名:', this.selectedMemberNames)
            })
          }
        } else {
          console.error('获取用户列表失败:', res)
          this.$message.error('获取用户列表失败')
        }
      })

      console.log('列表数据', row)
      this.departmentTake = {}
      this.medicalTake = {}
      this.ethicsTake = {}
      this.managerTake = { score: 60, auditStatus: 1, remarks: '60分' }

      this.hospitalTake = {}
      this.insuranceTake = {}
      this.financeTake = {}
      Promise.all([newWorkOrderList({ correlationId: row.id, pageSize: 0 }), getNewDeptList({ pageSize: 9999 }), newGetUserInfo()]).then(resArr => {
        const [circulationHistoryListData, deptData, userInfoData] = resArr
        console.log('用户信息', userInfoData)

        this.circulationHistoryList = circulationHistoryListData.records
        this.structureList = deptData.records
        this.models = row

        // 处理技术类别回显
        if (originalData.techType) {
          console.log('原始技术类别数据:', originalData.techType)
          // 将字符串格式的技术类别转换为数组
          this.techTypeArr = originalData.techType.split(',').map(Number)
          console.log('转换后的技术类别数组:', this.techTypeArr)
        }
        // 再次确保项目成员数据正确设置
        if (originalData && originalData.projectMember && this.allUsers && this.allUsers.length > 0) {
          const memberIds = originalData.projectMember.split(',').filter(id => id)
          this.models.projectMember = memberIds

          // 更新选中的成员姓名
          this.selectedMemberNames = memberIds.map(id => {
            const user = this.allUsers.find(u => u.id === Number(id) || u.id === id)
            return user ? user.name : ''
          }).filter(name => name)

          console.log('再次设置项目成员:', this.models.projectMember)
          console.log('再次设置成员姓名:', this.selectedMemberNames)
        }

        // 设置默认分数
        // if (this.models.status === 120) {
        //   this.ethicsTake.score = 60 // 默认分数
        //   this.ethicsTake.auditStatus = 1 // 默认审核状态
        // }

        // this.btnShow = status === 0 && currentUserId === auditUserId;
        this.btnShow = btnShow && row.auditStatus * 1 === 2
        this.dialogVisible = true

        // 清除表单验证
        this.$nextTick(() => {
          this.$refs['generateForm'].clearValidate()
        })
      }).catch(error => {
        console.error('加载数据失败:', error)
        this.$message.error('加载数据失败，请重试')
      })
    },
    getProcessNodeList(row) {
      this.models = row
      this.dialogVisible = true
    },
    submitAction() {
      const { id, name } = this.models
      const params = {
        id,
        remarks: '',
        auditStatus: 1,
        task: '',
        openTime: ''
      }
      if (this.models.status === 10 && this.departmentTake.auditStatus === 4 && !this.departmentTake.remarks) {
        this.$message.error('请填写驳回原因！')
        return false
      }
      if (this.models.status === 20 && this.medicalTake.auditStatus === 4 && !this.medicalTake.remarks) {
        this.$message.error('请填写驳回原因！')
        return false
      }
      if (this.models.status === 30 && this.ethicsTake.auditStatus === 4 && !this.ethicsTake.remarks) {
        this.$message.error('请填写驳回原因！')
        return false
      }
      if (this.models.status === 40 && this.hospitalTake.auditStatus === 4 && !this.hospitalTake.remarks) {
        this.$message.error('请填写驳回原因！')
        return false
      }
      switch (this.models.status) {
        case 10:
          // newDoApprove
          params.remarks = this.departmentTake.remarks
          params.auditStatus = this.departmentTake.auditStatus
          break
        case 20:
          params.remarks = this.medicalTake.remarks
          params.auditStatus = this.medicalTake.auditStatus
          break
        case 30:
          params.remarks = this.ethicsTake.remarks
          params.auditStatus = this.ethicsTake.auditStatus
          params.task = JSON.stringify(this.ethicsTake)
          break
        case 40:
          params.remarks = this.hospitalTake.remarks
          params.auditStatus = this.hospitalTake.auditStatus
          break
        case 50:
          params.task = JSON.stringify(this.insuranceTake)
          break
        case 60:
          this.financeTake.openTime = moment(this.financeTake.openTime).format('YYYY-MM-DD')
          params.openTime = this.financeTake.openTime
          params.task = JSON.stringify(this.financeTake)
          break
        case 70:
          break
        case 120:
          params.task = JSON.stringify(this.managerTake)
          params.auditStatus = this.managerTake.auditStatus
          params.remarks = this.managerTake.remarks || ''
          break
        default:
          break
      }

      console.log('提交的数据', params)

      newDoApprove(params).then(res => {
        console.log(res)
        this.$message({
          type: 'success',
          message: '提交成功!'
        })
        // this.auditStatus = 2
        this.submitDisabled = false
        this.handleClose()
        // this.$router.push({ path: '/project/applyList' })
      })
    },
    // 按部门分组用户
    groupAndDisplayUsers(users) {
      const deptMap = {}
      users.forEach(user => {
        if (!deptMap[user.depID]) {
          deptMap[user.depID] = {
            depID: user.depID,
            depName: user.depName || '未分配部门',
            users: []
          }
        }
        deptMap[user.depID].users.push(user)
      })

      // 部门内部按工号排序
      Object.values(deptMap).forEach(dept => {
        dept.users.sort((a, b) => (a.empNo || '').localeCompare(b.empNo || ''))
      })

      // 部门按名称排序
      this.displayUserGroups = Object.values(deptMap)
        .sort((a, b) => (a.depName || '').localeCompare(b.depName || ''))
        .filter(group => group.users.length > 0)

      console.log('分组后的部门数:', this.displayUserGroups.length)
      // 构建级联选择器数据
      this.buildCascaderOptions()
    },

    // 构建级联选择器数据
    buildCascaderOptions() {
      this.departmentUserOptions = this.displayUserGroups.map(dept => {
        return {
          id: dept.depID,
          name: dept.depName,
          children: dept.users.map(user => {
            return {
              id: user.id.toString(), // 确保 ID 为字符串类型
              name: user.name,
              empNo: user.empNo,
              depName: user.depName,
              groupName: user.groupName
            }
          })
        }
      })

      // 如果有项目成员数据，确保在构建完级联选择器数据后重新设置
      if (this.models && this.models.projectMember && Array.isArray(this.models.projectMember)) {
        console.log('级联选择器数据构建完成，重新设置项目成员:', this.models.projectMember)
        // 使用$nextTick确保DOM更新后再设置值
        this.$nextTick(() => {
          // 强制更新级联选择器的值
          const tempValue = [...this.models.projectMember]
          this.models.projectMember = []
          this.$nextTick(() => {
            this.models.projectMember = tempValue
          })
        })
      }
    },

    // 处理成员选择变化
    handleMemberChange(value) {
      console.log('选中的成员ID:', value)

      // 检查是否有部门ID被选中
      const selectedDeptIds = value.filter(id => {
        // 检查是否是部门ID（在departmentUserOptions中查找）
        return this.departmentUserOptions && this.departmentUserOptions.some(dept => dept.id === id)
      })

      // 如果有部门被选中，添加该部门下的所有人员
      if (selectedDeptIds.length > 0) {
        const allUserIds = new Set(value)

        // 遍历选中的部门，添加其下所有人员
        selectedDeptIds.forEach(deptId => {
          const dept = this.departmentUserOptions.find(d => d.id === deptId)
          if (dept && dept.children) {
            dept.children.forEach(user => {
              allUserIds.add(user.id)
            })
          }
        })

        // 更新选中的值
        this.models.projectMember = Array.from(allUserIds)
      } else {
        // 如果没有部门被选中，直接使用选中的值
        this.models.projectMember = value
      }

      // 更新选中的成员姓名
      this.selectedMemberNames = this.models.projectMember.map(id => {
        // 确保this.allUsers存在且是数组
        if (this.allUsers != undefined && this.allUsers && Array.isArray(this.allUsers)) {
          const user = this.allUsers.find(u => u.id === id)
          return user ? user.name : ''
        }
        return ''
      }).filter(name => name) // 过滤掉空值
    },

    // 搜索过滤方法
    filterNode(value, data) {
      if (!value) return true
      return data.name.toLowerCase().indexOf(value.toLowerCase()) !== -1 ||
             (data.empNo && data.empNo.toLowerCase().indexOf(value.toLowerCase()) !== -1)
    },

    // 处理搜索输入
    handleSearch(value) {
      this.$refs.memberTree.filter(value)
    },

    // 处理树形选择
    handleTreeCheck(data, checked) {
      const checkedNodes = this.$refs.memberTree.getCheckedNodes()
      // 过滤出用户节点（有empNo的节点）
      const selectedUsers = checkedNodes.filter(node => node.empNo)

      this.tempSelectedMembers = selectedUsers.map(user => user.id.toString()) // 确保 ID 为字符串
      this.tempSelectedNames = selectedUsers.map(user => user.name)
    },

    // 移除成员
    removeMember(index) {
      const memberId = this.tempSelectedMembers[index]
      this.tempSelectedMembers.splice(index, 1)
      this.tempSelectedNames.splice(index, 1)
      // 更新树的选中状态
      this.$refs.memberTree.setChecked(memberId, false, false)
    },

    // 打开成员选择对话框
    openMemberDialog() {
      // 保存当前的选择状态
      this.originalSelectedMembers = [...this.models.projectMember]
      this.originalSelectedNames = [...this.selectedMemberNames]

      // 初始化临时选择状态
      this.tempSelectedMembers = [...this.models.projectMember]
      this.tempSelectedNames = [...this.selectedMemberNames]

      this.memberDialogVisible = true

      // 在下一个 tick 设置树的选中状态
      this.$nextTick(() => {
        if (this.$refs.memberTree) {
          // 先清空所有选中状态
          this.$refs.memberTree.setCheckedKeys([])
          // 设置原始选中状态
          this.originalSelectedMembers.forEach(id => {
            this.$refs.memberTree.setChecked(id, true, false)
          })
        }
      })
    },

    // 取消选择
    cancelMemberSelect() {
      // 恢复到原始选择状态
      this.models.projectMember = [...this.originalSelectedMembers]
      this.selectedMemberNames = [...this.originalSelectedNames]
      this.selectedMemberText = this.originalSelectedNames.join('、')

      // 关闭对话框
      this.memberDialogVisible = false

      // 重置临时存储的数据
      this.tempSelectedMembers = []
      this.tempSelectedNames = []
      this.searchKeyword = ''
    },

    // 确认选择
    confirmMemberSelect() {
      // 更新选择结果
      this.models.projectMember = [...this.tempSelectedMembers]
      this.selectedMemberNames = [...this.tempSelectedNames]
      this.selectedMemberText = this.selectedMemberNames.join('、')

      // 关闭对话框
      this.memberDialogVisible = false

      // 重置临时数据
      this.tempSelectedMembers = []
      this.tempSelectedNames = []
      this.searchKeyword = ''
    },

    // 监听对话框关闭
    handleDialogClose() {
      this.cancelMemberSelect()
    },

    // 确保 ID 类型一致的辅助方法
    normalizeId(id) {
      return id.toString()
    },
    downLoadDoc(type) {
      var a = document.createElement('a')
      switch (type) {
        case 1:
          a.href =
            `/${this.globalConfig.folderName}/非限制类使用——${this.globalConfig.fullName}医疗技术临床应用审核申请书（操作技术）.docx`
          a.download =
            `非限制类使用——${this.globalConfig.fullName}医疗技术临床应用审核申请书（操作技术）.docx`
          break
        case 2:
          a.href =
            `/${this.globalConfig.folderName}/非限制类使用——${this.globalConfig.fullName}医疗技术临床应用审核申请书（检验检查）.docx`
          a.download =
            `非限制类使用——${this.globalConfig.fullName}医疗技术临床应用审核申请书（检验检查）.docx`
          break
        case 3:
          a.href = '/static/xjs/限制类备案使用——新技术备案申请表（样表）.docx'
          a.download = '限制类备案使用——新技术备案申请表（样表）.docx'
          break
        case 4:
          a.href = '/static/xjs/限制类备案使用——新技术备案申请表（样表）.docx'
          a.download = '限制类备案使用——新技术备案申请表（样表）.docx'
          break
        case 5:
          a.href = '/static/xjs/限制类备案使用——新技术备案申请表（样表）.docx'
          a.download = '限制类备案使用——新技术备案申请表（样表）.docx'
          break
      }
      a.style.display = 'none'
      document.body.appendChild(a)
      a.click()
      a.remove()
    },
    openHelp() {
      this.$refs.Tech.close()
      this.$refs.LimitTech.open()
    },
    openTech() {
      this.$refs.LimitTech.close()
      this.$refs.Tech.open()
    },
    outPutPdfFn() {
      const vm = this
      const A4_WIDTH = 592.28
      const A4_HEIGHT = 841.89 // $myLoading 自定义等待动画组件，实现导出事件的异步等待交互
      this.pdfLoading = true
      this.loadingFull = Loading.service({
        target: document.querySelector('.app-wrapper'),
        lock: true,
        text: '正在导出中，请稍后……',
        background: 'rgba(0, 0, 0, 0.7)',
        customClass: 'zIndex9999'
      })
      vm.$nextTick(() => {
        // dom的id。
        const target = document.getElementById('pdfHtml')
        const pageHeight = target.scrollWidth / A4_WIDTH * A4_HEIGHT
        // 获取分割dom，此处为class类名为item的dom
        const lableListID = document.getElementsByClassName('item-excel')
        // 进行分割操作，当dom内容已超出a4的高度，则将该dom前插入一个空dom，把他挤下去，分割
        for (let i = 0; i < lableListID.length; i++) {
          const multiple = Math.ceil((lableListID[i].offsetTop + lableListID[i].offsetHeight / 2) / pageHeight)
          if (this.isSplit(lableListID, i, multiple * pageHeight)) {
            const divParent = lableListID[i].parentNode
            // 获取该div的父节点
            const newNode = document.createElement('div')
            newNode.className = 'emptyDiv'
            newNode.style.background = '#ffffff'
            const _H = multiple * pageHeight - (lableListID[i].offsetTop + lableListID[i].offsetHeight)
            newNode.style.height = _H + 30 + 'px'
            newNode.style.width = '100%'
            const next = lableListID[i].nextSibling
            // 获取div的下一个兄弟节点
            // // 判断兄弟节点是否存在
            if (next) {
              // 存在则将新节点插入到div的下一个兄弟节点之前，即div之后
              divParent.insertBefore(newNode, next)
            } else {
              // 不存在则直接添加到最后,appendChild默认添加到divParent的最后
              divParent.appendChild(newNode)
            }
          }
        }
        // 传入title和dom标签，此处是 #content// 异步函数，导出成功后处理交互
        this.getPdf(`${this.models.name}`, '#pdfHtml').then(() => {}).catch(() => {})
        setTimeout(() => {
          this.loadingFull.close()
          this.pdfLoading = false
        }, 2000)
        this.pdfLoading = false
      })
    },
    isSplit(nodes, index, pageHeight) {
      // 计算当前这块dom是否跨越了a4大小，以此分割
      if (nodes[index].offsetTop + nodes[index].offsetHeight < pageHeight && nodes[index + 1] &&
        nodes[index + 1].offsetTop + nodes[index + 1].offsetHeight > pageHeight) { return true }
      return false
    },
    handlePrint(params) {
      printJS({
        maxWidth: 1920,
        documentTitle: `${this.globalConfig.fullName}医务一网通办`,
        printable: params.printable, // 'printFrom',
        type: params.type || 'html',
        header: params.header, // '表单',
        targetStyles: ['*'],
        ignoreElements: params.ignore || [], // ['no-print']
        properties: params.properties || null
      })
    },
    handleChange(v) {
      // getNewDeptInfo({ id: v }).then(res => {
      //   this.models.applyManagerId = res.records[0].deptManagerId
      // })
    },
    handleClose(val) {
      // this.$refs['ruleForm'].resetFields()
      this.dialogVisible = false
      this.$emit('refreshTable')
    },
    handleScoreChange(val) {
      if (val < 60) {
        this.managerTake.auditStatus = 4
        this.scoreResult = '不通过'
      } else {
        this.managerTake.auditStatus = 1
        this.scoreResult = '通过'
      }
      this.managerTake.remarks = `${val} 分`
    }
  }
}
</script>

<style lang="scss" scoped>
/* 去掉全选按钮 */
::v-deep .el-table .disabledCheck .cell .el-checkbox__inner {
    display: none !important;
}

::v-deep .el-table .disabledCheck .cell::before {
    content: "请选择";
    text-align: center;
    line-height: 37px;
}
.app-container {
    max-width: 1530px;
    margin: 0 auto;
    // background: #ebf4fa;
    border-radius: 12px;
    .apply-box {
        border-radius: 15px;
        .line {
            height: 22px;
            width: 5px;
            background: #277fd6;
        }
    }
    .history-box {
        border-radius: 15px;
        .line {
            height: 22px;
            width: 5px;
            background: #277fd6;
        }
    }
}
.red {
    color: red;
}
.green {
    color: green;
}
</style>
